package toponet.geometry;

public class Point {
	private double x;
	private double y;
	
	public Point(double x, double y) {
		this.x = x;
		this.y = y;
	}
	
	//temporary constructor, because messages only have a String-type data field. 
	public Point(String[] coordinate) { 
		this.x = Double.parseDouble(coordinate[0]);
		this.y = Double.parseDouble(coordinate[1]);
	}
	 
	public double getX() {
		return this.x;
	}

	public double getY() {
		return this.y;
	}
	
	// Return the euclidean distance of this point from another point
	
	public double euclideanDist(double x, double y) {
		return Math.sqrt(((this.x-x)*(this.x-x)+(this.y-y)*(this.y-y)));
	}
	
	public double euclideanDist(Point p) {
		return Math.sqrt(((this.x-p.getX())*(this.x-p.getX())+(this.y-p.getY())*(this.y-p.getY())));
	}
	
	public String toString() { 
		return this.x + "&" + this.y;
	}
}
